package org.jash.demo2205

import okhttp3.MultipartBody
import okhttp3.RequestBody
import org.jash.demo2205.entity.BannerEntity
import org.jash.demo2205.entity.CartItem
import org.jash.demo2205.entity.Category
import org.jash.demo2205.entity.Goods
import org.jash.demo2205.entity.Res
import org.jash.demo2205.entity.User
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query
import java.io.File

interface APIService {
    @POST("/user/loginjson")
    suspend fun login(@Body user:Map<String, String>):Res<User>
    @POST("/user/register")
    suspend fun register(@Body user:Map<String, String>):Res<User>
    @GET("/goods/info")
    suspend fun getGoods(@Query("category_id") cid:Int, @Query("currentPage") page:Int, @Query("pageSize") size:Int):Res<List<Goods>>
    @GET("/banner/json")
    suspend fun getBanners():Res<List<BannerEntity>>
    @GET("/goods/detail")
    suspend fun getGoodsDetail(@Query("goods_id") id:Int):Res<Goods>
    @POST("/goods/addCar")
    suspend fun addToCart(@Body cart:Map<String, Int>):Res<Any?>
    @GET("/goods/category")
    suspend fun getAllCategory():Res<List<Category>>
    @GET("/goods/selectCar")
    suspend fun getCart():Res<List<CartItem>>
    @POST("/goods/deleteCar")
    suspend fun deleteCart(@Body cart:Map<String, Int>):Res<Any?>
    @POST("/user/updateIcon")
    @Multipart
    suspend fun uploadIcon(@Part file: MultipartBody.Part):Res<String>
}